package com.rfid.afd.activity.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.rfid.afd.activity.SetLabelActivity;
import com.rfid.rls_psw.R;

import java.util.List;

public class SetLabAdapter extends RecyclerView.Adapter<SetLabAdapter.MyHolder> {

    List<SetLabelActivity.LabBean> mBeans;
    Context mContext;
    public SetLabAdapter(Context context, List<SetLabelActivity.LabBean> beans) {
        mContext = context;
        mBeans = beans;
    }

    @NonNull
    @Override
    public MyHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new MyHolder(LayoutInflater.from(mContext).inflate(R.layout.item_setlab_layout,parent,false));
    }

    @Override
    public void onBindViewHolder(@NonNull MyHolder holder, int position) {
        SetLabelActivity.LabBean bean = mBeans.get(position);
        holder.num.setText(position + "");
        holder.epc.setText(bean.originEpc);
        holder.barcode.setText(bean.barcode);
    }

    @Override
    public int getItemCount() {
        return mBeans.size();
    }

    class MyHolder extends RecyclerView.ViewHolder {
        TextView barcode;
        TextView epc;
        TextView num;
        public MyHolder(@NonNull View itemView) {
            super(itemView);
            barcode = itemView.findViewById(R.id.barcode);
            epc = itemView.findViewById(R.id.originEpc);
            num = itemView.findViewById(R.id.num);
        }
    }

}
